package com.klikmee.sms.core.base.communicator.telenor.longsms;

public class FiveBitHeaderExtractorImpl implements LongSMSExtractor {

	private int		messageIdStartIndex		= 6;
	private int		messageIdEndIndex		= 8;

	private int		numberOfPartsStartIndex	= 8;
	private int		numberOfPartsEndIndex	= 10;

	private int		curentPartStartIndex	= 10;
	private int		curentPartEndIndex		= 12;

	private int		headerLength			= 12;

	private String	messageBody				= null;

	public FiveBitHeaderExtractorImpl( String messageBody ) {
		this.messageBody = messageBody;
	}

	public String getLongMessageId() {
		
		return messageBody.substring( messageIdStartIndex, messageIdEndIndex );
	}

	public int getTotalNumberOfParts() {

		return Integer.parseInt( messageBody.substring( numberOfPartsStartIndex, numberOfPartsEndIndex ) );
	}

	public int getSequencePart() {
		return Integer.parseInt( messageBody.substring( curentPartStartIndex, curentPartEndIndex ) );
	}

	public void setMessageBody( String body ) {
		this.messageBody = body;
	}

	public String getMessageText() {
		
		return messageBody.substring( this.headerLength);
	}
}
